home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 85 / CDMM85_1.ISO / Science and Industry / si97a.exe / %MAINDIR% / si / events / colt.sc < prev    next >
Encoding:
Text File  |  2001-11-22  |  1.7 KB  |  66 lines

  1. // System-wide global variables
  2. $server = false;
  3. $localplayer = true;
  4. $origin = [ 0, 0, 0 ];
  5. $view_ofs = [ 0, 0, 0 ];
  6. $angles = [ 0, 0, 0 ];
  7. $gun_position [ 0, 0, 0 ];
  8. $gun_angles[ 0, 0, 0 ];
  9. $usehull = 0;
  10. $client_time = 0;
  11.  
  12. // 
  13. $snd = "";
  14. $model = "";
  15. $shell_origin = [ 0, 0, 0 ];
  16. $shell_velocity = [ 0, 0, 0 ];
  17. $forward = [ 0, 0, 0 ];
  18. $right   = [ 0, 0, 0 ];
  19. $up         = [ 0, 0, 0 ];
  20.  
  21. public Fire_Glock()
  22. {
  23.     // Play a sound
  24.     $snd = weapons/pl_gun3.wav;
  25.     $model = models/shell.mdl;
  26.  
  27.     Native_PlayPlayerSound( $player = $localplayer, $sound = $snd, $channel = CHAN_STATIC, $pitch = $def_pitch, $attenuation = $def_attn, $pitch = $def_pitch );
  28.  
  29.     // Eject shells
  30.     //
  31.     for ( $i = 0; $i < 2; $i++ )
  32.     {
  33.         $shell_origin   = $origin + $view_ofs;
  34.         $shell_velocity = $forward * 24 + right * 6 + $up * 20;
  35.  
  36.         $shell_angles = $angles;
  37.         $angles[0] = 0;
  38.         $angles[2] = 0;
  39.  
  40.         Native_CreateTempEntity
  41.         (
  42.             $te_origin = $shell_origin,
  43.             $te_angles = $angles,
  44.             $te_framemax = Native_FrameCountForModel( $model = $model ),
  45.             $te_flags = FTENT_COLLIDEWORLD | FTENT_GRAVITY | FTENT_ROTATE,
  46.             $te_hitSound = BOUNCE_SHELL;
  47.             $te_baselineangles = Native_RandomAngles(),
  48.             $te_basedirection  = $shell_velocity,
  49.             $te_die = $client_time + 3.5,
  50.             $te_body = Native_Random( 0, $te_framemax )
  51.         )
  52.  
  53.         // Now fire bullets
  54.         $start = $origin;
  55.         $end = $origin + 8192 * $gun_angles;
  56.  
  57.         Native_PerformTrace( $start = $start, $end = $end, $flags = PM_STUDIO_BOX );
  58.  
  59.         if ( $trace_fraction != 1.0 )
  60.         {
  61.             Native_PlaySoundAtPosition( $origin = $trace_endpos, $sound = weapons/bullet_hit1.wav );
  62.             Native_ImpactParticles( $origin = $trace_endpos );
  63.             Native_PlaceDecal( $origin = $trace_endpos, $decal = "{shot2", $trace_entity );
  64.         }
  65.     }
  66. }